<blockquote class="layui-elem-quote">{$title}</blockquote>
<from class="layui-form">
    <div class="layui-inline" style="width:400px;">
        <input type="text" class="layui-input" name="keyword" autocomplete="off" placeholder="请输入会员名称进行搜索">
    </div>
    <button class="layui-btn" type="button" lay-submit lay-filter="menu_search" id="reloadBtn"><i class="layui-icon">&#xe615;</i> 搜索</button>
</from>
<table class="layui-hide" id="LAY_table_menu" lay-filter="menu"></table>
<script type="text/html" id="is_frozenTpl">
    <input type="checkbox" name="is_frozen" value="{{d.user_id}}" lay-skin="switch" lay-text="是|否" {{ d.is_frozen == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="info"><i class="layui-icon">&#xe665;</i> 个人信息&ensp;</a>
    <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit"><i class="layui-icon">&#xe673;</i> 修改密码&ensp;</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="frozen"><i class="layui-icon">&#xe674;</i> 解除冻结&ensp;</a>
</script>
<script>
    layui.use(['table'], function(){
        var layui_table_scrollTop = 0;
        var table = layui.table,form = layui.form;
        form.render();
        //监听工具条
        table.on('tool(menu)', function(obj){
            layui_table_scrollTop = $(".layui-table-body.layui-table-main").scrollTop();
            var data = obj.data;
            if(obj.event === 'edit'){
                layer.prompt({title: '输入新密码', formType: 1}, function(pass, index){
                    layer.close(index);
                    post_sub("{:url('Users/editPassword')}",{user_id:data.user_id,password:pass});
                });
            }else if(obj.event === 'info'){
                layui_open("{:url('Users/userInfo')}",{user_id:data.user_id},data.nick_name+" - 个人信息","50%","60%",table);
            }else if(obj.event === 'frozen'){
                layer.confirm('确定要解除 《'+data.nick_name+' >> '+data.tel+'》 的冻结？', {
                    skin: 'layui-layer-lan',
                    title:'解除冻结',
                    btn: ['确定','取消'] //按钮
                }, function(){
                    post_sub("{:url('Users/unfreezing')}",{user_id:data.user_id},table);
                });
            }
        });
        //方法级渲染
        table.render({
            elem: '#LAY_table_menu'
            ,url: '{:url("Users/userList",["table"=>1])}'
            ,cellMinWidth: 80
            ,height: 'full-265'
            ,cols: [[
                {checkbox: true}
                ,{field:'user_id',title: 'ID',align:'center', width:80}
                ,{field:'nick_name',title: '姓名',align:'center'}
                ,{field:'tel',title: '电话',align:'center'}
                ,{field:'create_time',title: '注册时间',align:'center'}
                ,{field:'last_time',title: '最后登录时间',align:'center'}
                ,{field:'is_frozen',title: '冻结',align:'center',templet: '#is_frozenTpl', width:120}
                {empty name="SUBSTATIONS"},{field:'substation_name',title: '分站',align:'left'}{/empty}
                ,{title:'操作', toolbar: '#barDemo',align:'center', width:340}
            ]]
            ,id: 'testReload'
            ,page: true
            ,toolbar:"#toolbarDemo"
            ,defaultToolbar:{$defaultToolbar}
            ,limit:"{$limit}"
            ,limits:[{$limits}]
            ,done:function () {
                $(".layui-table-body.layui-table-main").scrollTop(layui_table_scrollTop);
                layui_table_scrollTop = 0;
            }
        });
        //头部工具条监听事件
        table.on('toolbar(menu)', function(obj){
            layui_table_scrollTop = $(".layui-table-body.layui-table-main").scrollTop();
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){

            };
        });

        //搜索重载表格
        form.on('submit(menu_search)', function(data){
            table.reload('testReload', {
                where: data.field,
                page: {
                    curr: 1
                }
            });
            return false;
        });

        $(".layui-form").keydown(function(event){
            var keycode = (event.keyCode ? event.keyCode : event.which);
            if(keycode == '13'){
                //回车触发
                $('#reloadBtn').trigger('click');
            }
        });
    });


</script>
</body>
</html>